It Works On My Machine - Reproducibility in R for Small Teams

Works on my machine - MS Teams sticker Melissa Albino Hegeman, October 19, 2023

Disclaimer

  • The opinions I’m presenting are my own and don’t reflect agency policy.

  • Images were generated with Adobe FireFly.

About Me

  • Marine biologist

  • Get really seasick

  • Work with fisheries data

How I Am Using R

  • Automate routine tasks
  • Generate individualized reports

What is a Team?

  • 10 people or less
  • Limited to no experience with R
  • No enterprise tools

Sharing the Load

  • What happens after you implement a big change?
  • Who is responsible for maintenance?
  • Who is responsible for new features?

Setting Up for Success

  • R projects
  • GitHub
  • Custom R package
  • {renv}

It Works on My Machine

  • Error in library(tidyverse) : there is no package called ‘tidyverse’

  • Error in plot(data) : object 'data' not found

  • Error in file(file_path, "r") : cannot open the connection

  • cannot create dir 'output', permission denied

How Do I Fix It?

  • R projects
  • GitHub
  • Custom R package
  • {renv}

R Projects

Issues

  • Not being used as intended

Successes

  • Relative file paths
  • First step in reproducibility
  • Adds portability

GitHub Repositories

Issues

  • Steep learning curve

Success

  • It’s the most efficient way to get the code on everyone’s machine

  • Gives team members the freedom to experiment

Custom R Package

Issues

  • Keeping everything in sync

  • Updates and maintenance

Successes

  • Everyone is applying the same treatment to the data no matter where they are working

{renv}

Issues

  • Slow to boot up a project for the first time

  • Staff were updating the lockfile rather than adjusting their installed packages when their project was out of sync

Successes

  • This is still a work in progress

  • Wait until you are done developing before you initialize {renv}

  • Forced me to minimize the amount of dependencies I use

Take Aways

  • Consistent and continued training for new staff

  • Simplify where ever you can

  • Avoid scope creep in your projects

Next Steps

Thank You

Melissa Albino Hegeman

https://github.com/mhegeman/2023_rgov